/*
 * @Author: fengYM feng25321@163.com
 * @Date: 2023-09-21 16:09:36
 * @LastEditors: fengYM feng25321@163.com
 * @LastEditTime: 2023-09-25 11:34:09
 * @Description:
 */
export default {
  data() {
    return {};
  },
  onLoad: function () {},
  mounted() {
    if (this.isWeiXinBrowser() || this.isQQBrowser()) {
      this.navTitle();
    }
  },
  methods: {
    isWeiXinBrowser() {
      let ua = navigator.userAgent.toLowerCase();
      return ua.indexOf("micromessenger") != -1;
    },
    isQQBrowser() {
      var ua = navigator.userAgent.toLowerCase();
      if (ua.match(/QQ/i) == "qq") {
        return true;
      } else {
        return false;
      }
    },
    navTitle() {
      this.$nextTick(() => {
        let navTitleDom = document.getElementsByTagName("uni-page-head");
        if (navTitleDom.length) {
          navTitleDom[0].style.display = "none";
        }
      });
    },
  },
};

export const TanPreviewImage = (imgs: any, iIndex: any) => {
  let images = [];
  images = [...imgs];
  uni.previewImage({
    current: iIndex,
    urls: images,
    longPressActions: {
      //长按保存图片到相册
      itemList: ["保存图片"],
      success: (data) => {
        uni.saveImageToPhotosAlbum({
          //保存图片到相册
          filePath: "payUrl",
          success: function () {
            uni.showToast({ icon: "success", title: "保存成功" });
          },
          fail: (err) => {
            uni.showToast({ icon: "none", title: "保存失败，请重新尝试" });
          },
        });
      },
    },
  });
};
export const goBack = () => {
  if (getCurrentPages().length > 1) {
    uni.navigateBack();
  } else {
    uni.switchTab({
      url: "/pages/home/home",
    });
  }
};
export const goPage = (url: string) => {
  uni.navigateTo({
    url,
  });
};
